package properties

import "time"

type BootstrapProperties struct {
	Sys   SysCoat         `mapstructure:"sys" json:"sys" yaml:"sys"`
	Nacos NacosProperties `mapstructure:"nacos" json:"nacos" yaml:"nacos"`
	Etcd  EtcdConfig      `mapstructure:"etcd" json:"etcd" yaml:"etcd"` // 添加 Etcd 配置
}

type SysCoat struct {
	Profile    Profile `mapstructure:"profile" json:"profile" yaml:"profile"`
	ConfigType string  `mapstructure:"config-type" json:"config-type" yaml:"config-type"`
}

type NacosProperties struct {
	Config NacosConfig `mapstructure:"config" json:"config" yaml:"config"`
}

type NacosConfig struct {
	Server []NacosConfigServer `mapstructure:"server" json:"server" yaml:"server"`
	Client NacosConfigClient   `mapstructure:"client" json:"client" yaml:"client"`
}

type NacosConfigServer struct {
	Scheme      string `mapstructure:"scheme" json:"scheme" yaml:"scheme"`                   // the nacos server scheme,default=http,this is not required in 2.0
	ContextPath string `mapstructure:"context-path" json:"context-path" yaml:"context-path"` // the nacos server contextpath,default=/nacos,this is not required in 2.0
	IpAddr      string `mapstructure:"ip-address" json:"ip-address" yaml:"ip-address"`       // the nacos server address
	Port        uint64 `mapstructure:"port" json:"port" yaml:"port"`                         // nacos server port
	GrpcPort    uint64 `mapstructure:"grpc-port" json:"grpc-port" yaml:"grpc-port"`
}

type NacosConfigClient struct {
	NamespaceId string `mapstructure:"namespace-id" json:"namespace-id" yaml:"namespace-id"`
	Username    string `mapstructure:"username" json:"username" yaml:"username"`
	Password    string `mapstructure:"password" json:"password" yaml:"password"`
	// timeout for requesting Nacos server, default value is 10000ms
	TimeoutMs uint64                     `mapstructure:"timeout-ms" json:"timeout-ms" yaml:"timeout-ms"`
	LogDir    string                     `mapstructure:"log-dir" json:"log-dir" yaml:"log-dir"`
	LogLevel  string                     `mapstructure:"log-level" json:"log-level" yaml:"log-level"`
	CacheDir  string                     `mapstructure:"cache-dir" json:"cache-dir" yaml:"cache-dir"`
	Configs   []NacosConfigClientConfigs `mapstructure:"configs" json:"configs" yaml:"configs"`
}

type NacosConfigClientConfigs struct {
	Group  string `mapstructure:"group" json:"group" yaml:"group"`
	DataId string `mapstructure:"data-id" json:"data-id" yaml:"data-id"`
}

type EtcdConfig struct {
	Endpoints   []string      `mapstructure:"endpoints" json:"endpoints" yaml:"endpoints"`
	DialTimeout time.Duration `mapstructure:"dial-timeout" json:"dial-timeout" yaml:"dial-timeout"`
	Username    string        `mapstructure:"username" json:"username" yaml:"username"` // 新增: etcd 认证用户名
	Password    string        `mapstructure:"password" json:"password" yaml:"password"` // 新增: etcd 认证密码
}
